package utils;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;


@SuppressLint("CommitPrefEdits")
public class SharedPreUtil {
    private SharedPreferences sp;
    private SharedPreferences.Editor editor;

    public SharedPreUtil(Context context, String fileName) {
        sp = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
        editor = sp.edit();

    }

    public void setFirstRun(Boolean FirstRun) {

        String FirstRunString = "FirstRun"
                + PhoneInformationUtil.getVersionCode();
        editor.putBoolean(FirstRunString, FirstRun);
        editor.commit();
    }

    public Boolean getFirstRun() {
        String FirstRunString = "FirstRun"
                + PhoneInformationUtil.getVersionCode();
        return sp.getBoolean(FirstRunString, true);
    }

    public void setSdk(int font_size) {
        editor.putInt("sdk", font_size);
        editor.commit();
    }

    public int getSdk() {
        return sp.getInt("sdk", 0);
    }

    public void setScreen_h(int Screen_h) {
        editor.putInt("Screen_h", Screen_h);
        editor.commit();
    }

    public int getScreen_h() {
        return sp.getInt("Screen_h", 0);
    }

    public void setScreen_w(int Screen_w) {
        editor.putInt("Screen_w", Screen_w);
        editor.commit();
    }

    public int getScreen_w() {
        return sp.getInt("Screen_w", 0);
    }

    public void setRuningState(int RuningState) {
        editor.putInt("RuningState", RuningState);
        editor.commit();
    }

    public int getRuningState() {
        return sp.getInt("RuningState", 0);
    }

    public void setToken(String Token) {
        editor.putString("Token", Token);
        editor.commit();
    }

    public String getToken() {
        return sp.getString("Token", "");
    }
    public void setUid(String Uid) {
        editor.putString("Uid", Uid);
        editor.commit();
    }

    public String getUid() {
        return sp.getString("Uid", "");
    }

    public void setDeviceToken(String DeviceToken) {
        editor.putString("DeviceToken", DeviceToken);
        editor.commit();
    }
    public String getDeviceToken() {
        return sp.getString("DeviceToken", "");
    }
}
